using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DAO;
using DTO;


namespace Presentation
{
    public partial class FrmDangNhap : Form
    {
        public static string ten;
        public static int manhanvien;
        public static NhanVienDto nv;
        public FrmDangNhap()
        {
            InitializeComponent();
        }

        private void frmDangNhap_Load(object sender, EventArgs e)
        {

        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            NhanvienDao nhanvienDao = new NhanvienDao();
            //NhanVienDto nhanvienDto = nhanvienDao.Select(txtTendangnhap.Text, txtMatkhau.Text);
            nv = nhanvienDao.Select(txtTendangnhap.Text, txtMatkhau.Text);
            if (nv!= null)
            {
                ten = nv.TenNhanVien;
                manhanvien = nv.Id;
                Hide();
                new FrmQuanlynhathuoc().Show();
            }

            DuocPhamDao dpDao = new DuocPhamDao();
            DuocPhamDto[] dpDto = dpDao.SelectHangganhet();
            if (nv != null)
            {
                if (dpDto.Length > 0 && nv.PhanQuyen.Id == 2)
                {
                    FrmHangGanHet frm = new FrmHangGanHet();
                    frm.ShowDialog();
                    return;
                }
                DuocPhamDto[] canngay = dpDao.SelectHangcanngay(30);
                if (canngay.Length > 0 && nv.PhanQuyen.Id == 2)
                {
                    FrmHangGanHet frm = new FrmHangGanHet();
                    frm.ShowDialog();
                    return;
                }
            }
        }
    }
}